<?php require admin_tpl('header');?>

<div class="tab">
	<ul>
		<li><a href="?mod=tag" <?php echo $tab['list']?>>标签列表</a></li>
		<li><a href="?mod=tag&ac=add" <?php echo $tab['add']?>><?php echo $do == 'edit' ? '编辑标签' : '添加标签';?></a></li>
	</ul>
</div>
<div class="main">

<?php if ($ac == 'list') {?>
	<div class="search">
		<form name="search" method="get" action="admin.php">
		<input type="hidden" name="mod" value="tag" />
			<fieldset>
				<legend>标签查找</legend>
					文章数：
					<input type="text" name="min" size="6" value="<?php echo $min?>" /> -
					<input type="text" name="max" size="6" value="<?php echo $max?>" />
					关键字：
					<input type="text" name="keyword" size="15" value="<?php echo $keyword?>" />
					<input type="submit" name="s" class="button" value="开始查找" />
					<input type="button" class="button" value="所有标签" onclick="window.location.href='admin.php?mod=tag'" />
			</fieldset>
		</form>
	</div>
	<form name="op" method="post" action="?mod=tag">
	<input type="hidden" name="dosubmit" value="yes" />
		<table class="datalist" cellspacing="0" id="list">
			<tr>
				<th width="50" class="firstcol">选择</th>
				<th width="300">名称</th>
				<th width="100">文章数</th>
				<th>&nbsp;</th>
			</tr>
			<?php
			if ( $result ) {
				foreach ($result as $row) { ?>
			<tr id="row_<?php echo $row['id']?>">
				<td align="center"><input type="checkbox" name="id[]" value="<?php echo $row['id']?>" class="checkbox" /></td>
				<td><a href="?mod=tag&ac=edit&id=<?php echo $row['id']?>"><?php echo $row['tagname']?></a></td>
				<td align="center"><b style="color:red"><?php echo $row['count']?></b></td>
				<td>&nbsp;</td>
			</tr>
			<?php
				}
			} else {
				echo '<tr><td colspan="10">暂无记录...</td></tr>';
			}
			?>
			<tr>
				<td align="center">
				<input type="checkbox" class="checkbox" value="1" name="chkall" onclick="check_all(this)" /></td>
				<td colspan="4">
				全选
				<input type="radio" name="ac" value="recount" id="recount" checked="checked" class="checkbox" /><label for="recount">更新统计</label>
				<input type="radio" name="ac" value="del" id="del" class="checkbox" /><label for="delete">删除</label>
				<input type="radio" name="ac" value="merge" id="merge" class="checkbox" /><label for="merge">合并到：</label>
				<input type="text" name="newtag" onclick="$('#merge').attr('checked',true)" size="8" style="display:inline" />
				<input type="submit" name="submit" value="执行操作" class="submit" />
				</td>
			</tr>
			<tr>
				<td colspan="5"><?php echo multipage(); ?></td>
			</tr>
		</table>
	</form>

<?php } elseif ( $ac == 'add' || $ac == 'edit' ) { ?>
<table cellspacing="5">
	<tr>
		<td>
		<form name="edit" method="post" action="?mod=tag&ac=add" onsubmit="return check_tag_add()">
		<input type="hidden" name="dosubmit" value="yes" />
		<input type="hidden" name="id" value="<?php echo $result['id']?>" />
			标签名称：<input type="text" name="tagname" size="20" class="input" value="<?php echo $result['tagname']?>" /> <input type="submit" class="button" name="submit" value=" 保 存 " />
		</form>
		</td>
	</tr>
</table>
<?php }?>

</div>

<?php require admin_tpl('footer');?>